Skip to content

Conversation

@sunyuhan1998
Copy link
Contributor

Spring AI provides three starters for MCP servers: spring-ai-starter-mcp-server, spring-ai-starter-mcp-server-webmvc, and spring-ai-starter-mcp-server-webflux, among which spring-ai-starter-mcp-server-webflux is designed for reactive projects.

However, due to Spring Boot's default behavior, if both org.springframework.web.servlet.DispatcherServlet and org.springframework.web.reactive.DispatcherHandler are present in the classpath, Spring Boot will prioritize the former:

https://github.com/spring-projects/spring-boot/blob/0daf3f5897a9bad169ad7ebad6d79e4260a24822/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/WebApplicationType.java#L60-L71

This means that if users mistakenly use spring-ai-starter-mcp-server-webflux in a project built with spring-boot-starter-web, MCP endpoints such as /sse will become non-functional.

Of course, this is not an issue with Spring AI itself. However, considering that it has already caused considerable confusion :

I believe adding appropriate documentation would help users better understand what they are doing and avoid such pitfalls.

…rding `Starter` selection, and added descriptions of precautions for `spring-ai-starter-mcp-server-webflux`.

Signed-off-by: Sun Yuhan <[email protected]>
@sunyuhan1998
Copy link
Contributor Author

Hi @ilayaperumalg what do you think of this?

Copy link
Contributor

@yuluo-yx yuluo-yx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

BTW, I think this can solve the problem you are facing now, or we can also solve it through configuration?

such as spring.main.web-application-type=reactive.
Should this be added to the documentation?

@sunyuhan1998
Copy link
Contributor Author

sunyuhan1998 commented Jun 12, 2025

BTW, I think this can solve the problem you are facing now, or we can also solve it through configuration?

such as spring.main.web-application-type=reactive. Should this be added to the documentation?

Yes, we can indeed solve this issue through this configuration. I had also considered documenting this configuration, but ultimately, I thought that if users are using other components in their projects that depend on WebMvc, applying this configuration might lead to some unintended side effects. Therefore, the best approach may be to guide users to use the appropriate Starter, rather than using spring-ai-starter-mcp-server-webflux in a WebMvc project, since doing so would be meaningless.

@sobychacko sobychacko added this to the 1.1.x milestone Jun 13, 2025
@sobychacko sobychacko added for: backport-to-1.0.x documentation Improvements or additions to documentation MCP labels Jun 13, 2025
@sobychacko sobychacko merged commit 384478e into spring-projects:main Jun 13, 2025
2 checks passed
spring-builds pushed a commit that referenced this pull request Jun 13, 2025
- Improved the documentation in the `MCP Server Boot Starter` regarding `Starter` selection,
   and added descriptions of precautions for `spring-ai-starter-mcp-server-webflux`.

Fixes: #3511

Signed-off-by: Sun Yuhan <[email protected]>
(cherry picked from commit 384478e)
scionaltera pushed a commit to scionaltera/spring-ai that referenced this pull request Sep 3, 2025
- Improved the documentation in the `MCP Server Boot Starter` regarding `Starter` selection, 
   and added descriptions of precautions for `spring-ai-starter-mcp-server-webflux`. 

Fixes: spring-projects#3511

Auto-cherry-pick to 1.0.x

Signed-off-by: Sun Yuhan <[email protected]>
chedim pushed a commit to couchbaselabs/spring-ai that referenced this pull request Sep 19, 2025
- Improved the documentation in the `MCP Server Boot Starter` regarding `Starter` selection, 
   and added descriptions of precautions for `spring-ai-starter-mcp-server-webflux`. 

Fixes: spring-projects#3511

Auto-cherry-pick to 1.0.x

Signed-off-by: Sun Yuhan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants